package com.ss.android.common.ui.view;

import android.content.Context;
import android.util.AttributeSet;

public class SwitchButton extends MySwitch {
    public interface a {
        boolean a(boolean arg1);
    }

    private a a;

    public SwitchButton(Context arg1) {
        super(arg1);
    }

    public SwitchButton(Context arg1, AttributeSet arg2) {
        super(arg1, arg2);
    }

    public SwitchButton(Context arg1, AttributeSet arg2, int arg3) {
        super(arg1, arg2, arg3);
    }

    protected final void a(boolean arg1) {
        this.setCheckedWithListener(arg1);
    }

    public void setCheckedWithListener(boolean arg2) {
        if(arg2 != this.isChecked()) {
            if(this.a != null && !this.a.a(arg2)) {
                arg2 = !arg2 ? true : false;
            }

            this.setChecked(arg2);
        }
    }

    public void setOnCheckStateChangeListener(a arg1) {
        this.a = arg1;
    }

    public void toggle() {
        boolean v0 = !this.isChecked() ? true : false;
        this.setCheckedWithListener(v0);
    }
}

